<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>固定定位</title>
	<style type="text/css">

		/*在使用绝对定位还总,一般要在父级中设置相对定位,并且不偏移*/
		.con{
			width: 400px;
			height: 400px;
			border: 1px solid #000;
			margin: 100px auto 0;
			position: relative;
		}

		.con div{
			width: 200px;
			height: 100px;
			margin: 20px;
			background-color: gold;
			text-align: center;
			font-size: 40px;
			position: absolute;
		}

		/*在选择器前面加上Body可以加高它的权重,即如果修改颜色的话就会显示自有的独特颜色*/
		body .box1{
			background-color: green;
			z-index: 10; /*元素层级*/
		}

		body .box2{
			left: 50px;
			top: 50px;
			background-color: pink;
		}
		.box3{
			background-color: pink;
			left: 100px;
			top: 100px;
		}
	</style>
</head>
<body>
	<div class="con">
		<div class="box1">1</div>
		<div class="box2">2</div>
		<div class="box3">3</div>
	</div>

	<div class="box2">第四个盒子</div>
</body>
</html>